package cn.boot1112.spingboot.dao;

import cn.boot1112.spingboot.Mapper.UserMapper;
import cn.boot1112.spingboot.entity.User;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;

import javax.sql.DataSource;
import java.sql.SQLException;
@RunWith(SpringRunner.class)
@SpringBootTest
public class daotest {
    @Autowired
    DataSource dataSource;
    @Test
    public void getConnection() throws SQLException {
        System.err.println(dataSource.getConnection());
    }

    @Autowired
    UserMapper userMapper;

    @Test
    public void findByUsername() {
        String username = "张书宝";
        User result = userMapper.findByUsername(username);
        System.err.println(result);
    }
}
